package com.lgy.springboot_example.controller;

import com.lgy.springboot_example.entity.OrderInfo;
import com.lgy.springboot_example.utils.DataResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Api(tags = "Thymeleaf Demo")
@Controller
public class ThymeleafController {

    @ApiOperation("跳转静态thymeleaf")
    @GetMapping("/html")
    public String index() {
        return "mydata";
    }

    @ApiOperation("请求数据")
    @GetMapping("/getInfo")
    @ResponseBody
    public DataResult<Object> getInfo() {
        List<OrderInfo> data = new ArrayList<>();
        data.add(new OrderInfo(1, "上衣", new Date(), 1));
        data.add(new OrderInfo(2, "裤子", new Date(), 1));
        data.add(new OrderInfo(3, "鞋子", new Date(), 2));
        data.add(new OrderInfo(4, "帽子", new Date(), 2));
        return new DataResult<>(data);
    }
}
